// pages/sanhuiyike/sanhuiyike.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    subject:'',
    location:'',
    content:'',
    time:'',
    show:false,//弹出层绑定的变量，true为显示,false为隐藏
    minDate:new Date().getTime(),
    maxDate:new Date(2020,11,1).getTime(),
    //当前时间
    currentDate:new Date().getTime()
  },
  //时间格式化
  formDateTime(inputTime){
    let date = new Date(inputTime);
    let y = date.getFullYear();
    let m = date.getMonth() + 1;
    m =m <10 ? ('0' + m) : m;
    let d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    let h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    let minute =date.getMinutes();
    let second =date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second <10 ? ('0' + second ) : second;
    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
  },
  //时间确定选择
  onConfirm(event){
    console.log(event)
    //保存当前时间戳
    let currentTimeStap = event.detail
    let cureentdate = this.formDateTime(currentTimeStap)
    console.log(cureentdate)
    this.setData({time:cureentdate})
    this.showPopup()
  },
  //时间选择
  onInput(event){
    this.setData({
      currentDate:event.detail
    });
  },
  //打开弹出层
  showPopup(){
    //修改弹出层绑定的变量
    this.setData({show:!this.data.show})
  },
save(){
  console.log('data=')
  console.log(this.data)
},
onChange(event){
  console.log(event.detail);
  this.setData({'subject':event.detail})
},
onLocationChange(event) {
  console.log(event.detail);
  this.setData({ 'location': event.detail})
},
onContentChange(event) {
  console.log(event.detail);
  this.setData({ 'content': event.detail})
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})